package com.digitalart.site.commons {
	import flash.display.Stage;
	import flash.display.DisplayObject;

	/**
	 * @author johan.chaves
	 */
	public class DisplayObjectFinder {
		
		public static function getParent(child : DisplayObject,parentClass : Class):DisplayObject{
			var parent : DisplayObject;
			var found : Boolean = false;
			while(!found){
				if(child is Stage){
					return null;					
				}else if(child.parent is parentClass){
					found = true;
					parent = child.parent;
				}else{
					child = child.parent;
				}
			}
			return parent;
		}
		
	}
}
